home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gcc / ixemlsdk.lha / include / sys / socket.h < prev    next >
C/C++ Source or Header  |  1996-03-13  |  9KB  |  248 lines

  1. /*
  2.  * Copyright (c) 1982,1985,1986,1988 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)socket.h    7.13 (Berkeley) 4/20/91
  34.  *    really an older version, to match up with Commodore inet.library
  35.  */
  36.  
  37. #ifndef _SYS_SOCKET_H
  38. #define _SYS_SOCKET_H
  39.  
  40. /* for the sake of libg++ ... */
  41. #include <sys/types.h>
  42.  
  43. /*
  44.  * Definitions related to sockets: types, address families, options.
  45.  */
  46.  
  47. /*
  48.  * Types
  49.  */
  50. #define    SOCK_STREAM    1        /* stream socket */
  51. #define    SOCK_DGRAM    2        /* datagram socket */
  52. #define    SOCK_RAW    3        /* raw-protocol interface */
  53. #define    SOCK_RDM    4        /* reliably-delivered message */
  54. #define    SOCK_SEQPACKET    5        /* sequenced packet stream */
  55.  
  56. /*
  57.  * Option flags per-socket.
  58.  */
  59. #define    SO_DEBUG    0x0001        /* turn on debugging info recording */
  60. #define    SO_ACCEPTCONN    0x0002        /* socket has had listen() */
  61. #define    SO_REUSEADDR    0x0004        /* allow local address reuse */
  62. #define    SO_KEEPALIVE    0x0008        /* keep connections alive */
  63. #define    SO_DONTROUTE    0x0010        /* just use interface addresses */
  64. #define    SO_BROADCAST    0x0020        /* permit sending of broadcast msgs */
  65. #define    SO_USELOOPBACK    0x0040        /* bypass hardware when possible */
  66. #define    SO_LINGER    0x0080        /* linger on close if data present */
  67. #define    SO_OOBINLINE    0x0100        /* leave received OOB data in line */
  68.  
  69. /*
  70.  * Additional options, not kept in so_options.
  71.  */
  72. #define SO_SNDBUF    0x1001        /* send buffer size */
  73. #define SO_RCVBUF    0x1002        /* receive buffer size */
  74. #define SO_SNDLOWAT    0x1003        /* send low-water mark */
  75. #define SO_RCVLOWAT    0x1004        /* receive low-water mark */
  76. #define SO_SNDTIMEO    0x1005        /* send timeout */
  77. #define SO_RCVTIMEO    0x1006        /* receive timeout */
  78. #define    SO_ERROR    0x1007        /* get error status and clear */
  79. #define    SO_TYPE        0x1008        /* get socket type */
  80.  
  81. /*
  82.  * Structure used for manipulating linger option.
  83.  */
  84. struct    linger {
  85.     int    l_onoff;        /* option on/off */
  86.     int    l_linger;        /* linger time */
  87. };
  88.  
  89. /*
  90.  * Level number for (get/set)sockopt() to apply to socket itself.
  91.  */
  92. #define    SOL_SOCKET    0xffff        /* options for socket level */
  93.  
  94. /*
  95.  * Address families.
  96.  */
  97. #define    AF_UNSPEC    0        /* unspecified */
  98. #define    AF_UNIX        1        /* local to host (pipes, portals) */
  99. #define    AF_INET        2        /* internetwork: UDP, TCP, etc. */
  100. #define    AF_IMPLINK    3        /* arpanet imp addresses */
  101. #define    AF_PUP        4        /* pup protocols: e.g. BSP */
  102. #define    AF_CHAOS    5        /* mit CHAOS protocols */
  103. #define    AF_NS        6        /* XEROX NS protocols */
  104. #define    AF_ISO        7        /* ISO protocols */
  105. #define    AF_OSI        AF_ISO
  106. #define    AF_ECMA        8        /* european computer manufacturers */
  107. #define    AF_DATAKIT    9        /* datakit protocols */
  108. #define    AF_CCITT    10        /* CCITT protocols, X.25 etc */
  109. #define    AF_SNA        11        /* IBM SNA */
  110. #define AF_DECnet    12        /* DECnet */
  111. #define AF_DLI        13        /* DEC Direct data link interface */
  112. #define AF_LAT        14        /* LAT */
  113. #define    AF_HYLINK    15        /* NSC Hyperchannel */
  114. #define    AF_APPLETALK    16        /* Apple Talk */
  115. #define    AF_ROUTE    17        /* Internal Routing Protocol */
  116. #define    AF_LINK        18        /* Link layer interface */
  117. #define    pseudo_AF_XTP    19        /* eXpress Transfer Protocol (no AF) */
  118.  
  119. #define    AF_MAX        20
  120.  
  121. /*
  122.  * Structure used by kernel to store most
  123.  * addresses.
  124.  */
  125. #ifdef KERNEL
  126. struct TCP_sockaddr {
  127.     u_char    sa_len;         /* structure length */
  128.     u_char    sa_family;        /* address family */
  129.     char    sa_data[14];        /* up to 14 bytes of direct address */
  130. };
  131. #endif
  132. struct sockaddr {
  133.     u_short    sa_family;        /* address family */
  134.     char    sa_data[14];        /* up to 14 bytes of direct address */
  135. };
  136.  
  137.  
  138. /*
  139.  * Structure used by kernel to pass protocol
  140.  * information in raw sockets.
  141.  */
  142. struct sockproto {
  143.     u_short    sp_family;        /* address family */
  144.     u_short    sp_protocol;        /* protocol */
  145. };
  146.  
  147. /*
  148.  * Protocol families, same as address families for now.
  149.  */
  150. #define    PF_UNSPEC    AF_UNSPEC
  151. #define    PF_UNIX        AF_UNIX
  152. #define    PF_INET        AF_INET
  153. #define    PF_IMPLINK    AF_IMPLINK
  154. #define    PF_PUP        AF_PUP
  155. #define    PF_CHAOS    AF_CHAOS
  156. #define    PF_NS        AF_NS
  157. #define    PF_NBS        AF_NBS
  158. #define    PF_ECMA        AF_ECMA
  159. #define    PF_DATAKIT    AF_DATAKIT
  160. #define    PF_CCITT    AF_CCITT
  161. #define    PF_SNA        AF_SNA
  162. #define PF_DECnet    AF_DECnet
  163. #define PF_DLI        AF_DLI
  164. #define PF_LAT        AF_LAT
  165. #define    PF_HYLINK    AF_HYLINK
  166. #define    PF_APPLETALK    AF_APPLETALK
  167.  
  168. #define    PF_MAX        AF_MAX
  169.  
  170. /*
  171.  * Maximum queue length specifiable by listen.
  172.  */
  173. #define    SOMAXCONN    5
  174.  
  175. /*
  176.  * Message header for recvmsg and sendmsg calls.
  177.  */
  178. struct msghdr {
  179.     caddr_t    msg_name;        /* optional address */
  180.     int    msg_namelen;        /* size of address */
  181.     struct    iovec *msg_iov;        /* scatter/gather array */
  182.     int    msg_iovlen;        /* # elements in msg_iov */
  183.     caddr_t    msg_accrights;        /* access rights sent/received */
  184.     int    msg_accrightslen;
  185. };
  186.  
  187. #define    MSG_OOB        0x1        /* process out-of-band data */
  188. #define    MSG_PEEK    0x2        /* peek at incoming message */
  189. #define    MSG_DONTROUTE    0x4        /* send without using routing tables */
  190. #define    MSG_EOR        0x8        /* data completes record */
  191. #define    MSG_TRUNC    0x10        /* data discarded before delivery */
  192. #define    MSG_CTRUNC    0x20        /* control data lost before delivery */
  193. #define    MSG_WAITALL    0x40        /* wait for full request or error */
  194.  
  195. #define    MSG_MAXIOVLEN    16
  196.  
  197. /*
  198.  * Header for ancillary data objects in msg_control buffer.
  199.  * Used for additional information with/about a datagram
  200.  * not expressible by flags.  The format is a sequence
  201.  * of message elements headed by cmsghdr structures.
  202.  */
  203. struct cmsghdr {
  204.     u_int    cmsg_len;        /* data byte count, including hdr */
  205.     int    cmsg_level;        /* originating protocol */
  206.     int    cmsg_type;        /* protocol-specific type */
  207. /* followed by    u_char  cmsg_data[]; */
  208. };
  209.  
  210. /* given pointer to struct adatahdr, return pointer to data */
  211. #define    CMSG_DATA(cmsg)        ((u_char *)((cmsg) + 1))
  212.  
  213. /* given pointer to struct adatahdr, return pointer to next adatahdr */
  214. #define    CMSG_NXTHDR(mhdr, cmsg)    \
  215.     (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
  216.         (mhdr)->msg_control + (mhdr)->msg_controllen) ? \
  217.         (struct cmsghdr *)NULL : \
  218.         (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len)))
  219.  
  220. #define    CMSG_FIRSTHDR(mhdr)    ((struct cmsghdr *)(mhdr)->msg_control)
  221. /* "Socket"-level control message types: */
  222. #define    SCM_RIGHTS    0x01        /* access rights (array of int) */
  223.  
  224. #include <sys/cdefs.h>
  225.  
  226. __BEGIN_DECLS
  227. int    accept __P((int, struct sockaddr *, int *));
  228. int    bind __P((int, const struct sockaddr *, int));
  229. int    connect __P((int, const struct sockaddr *, int));
  230. int    getpeername __P((int, struct sockaddr *, int *));
  231. int    getsockname __P((int, struct sockaddr *, int *));
  232. int    getsockopt __P((int, int, int, void *, int *));
  233. int    listen __P((int, int));
  234. int    recv __P((int, void *, int, int));
  235. int    recvfrom __P((int, void *, int, int,
  236.         struct sockaddr *, int *));
  237. int    recvmsg __P((int, struct msghdr *, int));
  238. int    send __P((int, const void *, int, int));
  239. int    sendto __P((int, const void *, int, int, const struct sockaddr *, int));
  240. int    sendmsg __P((int, const struct msghdr *, int));
  241. int    setsockopt __P((int, int, int, const void *, int));
  242. int    shutdown __P((int, int));
  243. int    socket __P((int, int, int));
  244. int    socketpair __P((int, int, int, int *));
  245. __END_DECLS
  246.  
  247. #endif /* _SYS_SOCKET_H */
  248.